package pers.vic.blog.module.api.task.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.vic.boot.base.controller.BaseController;

import pers.vic.blog.module.api.task.service.BlogTaskJobService;  
import pers.vic.blog.module.api.task.model.BlogTaskJob;
import pers.vic.boot.base.model.BaseResponse;
import pers.vic.boot.base.vo.BooleanWithMsg;

/**
 * @description:博客定时任务 控制层
 * @author Vic.xu
 * @date: 2020-09-02 17:41
 */
@RestController
@RequestMapping("/blog/taskJob")
public class BlogTaskJobController extends BaseController<BlogTaskJobService, BlogTaskJob>{


    /**
     * 操作定时任务 运行/暂停/删除
     * @return
     */
    @RequestMapping("/operate")
    public BaseResponse operate(int id, int status) {
        BooleanWithMsg msg = service.operate(id, status);
        return BaseResponse.judge(msg.isSuccess()).setMsg(msg.getMessage());
    }


    /**
     * 立即执行任务
     * @return
     */
    @RequestMapping("/runJob")
    public BaseResponse runJob(int id){
        BooleanWithMsg msg = service.runJob(id);
        return BaseResponse.judge(msg.isSuccess()).setMsg(msg.getMessage());
    }



}
